Skip to content

Add Object, Interface, and Input type components for rendering GraphQL type declarations.#91

Open
FionaBronwen wants to merge 8 commits into
feature/graphqlfrom
fionabronwen/graphql-components-2-v2
Open

Add Object, Interface, and Input type components for rendering GraphQL type declarations.#91
FionaBronwen wants to merge 8 commits into
feature/graphqlfrom
fionabronwen/graphql-components-2-v2

Conversation

@FionaBronwen

Copy link
Copy Markdown

Summary

  • ObjectType - Renders GraphQL object types with fields, interface implementations, and operation
    fields
  • InterfaceType - Renders GraphQL interface types (models marked with @Interface)
  • InputType - Renders GraphQL input object types

The mutation engine handles all type naming during mutation, so components can simply use type.name
directly.

Changes

New Components

ObjectType (src/components/types/object-type.tsx)

  • Renders model properties as GraphQL fields
  • Supports interface implementations via @compose decorator
  • Supports operation fields via @operationFields decorator

InterfaceType (src/components/types/interface-type.tsx)

  • Renders models marked with @Interface as GraphQL interface types
  • Includes all model properties as interface fields

InputType (src/components/types/input-type.tsx)

  • Renders input object types for operation parameters
  • The mutation engine handles the "Input" suffix naming

Simplification

Removed the modelVariants lookup from InputType and GraphQLTypeExpression since the mutation
engine now handles all input/output type naming. Components use type.name directly.

Test plan

  • ObjectType tests (10 tests) - fields, descriptions, interfaces, operation fields, empty type
    error
  • InterfaceType tests (5 tests) - fields, descriptions, empty type error
  • InputType tests (5 tests) - fields, descriptions, arrays, empty type error
  • All 249 tests pass

Add field-bearing type components that use the Field infrastructure
(already present from the parent branch):
- ObjectType: renders object types with fields, @compose interfaces,
  and @operationFields support
- InterfaceType: renders interface type definitions with fields
- InputType: renders input types with automatic Input suffix when a
  model appears in both input and output positions

17 new component tests covering: basic field rendering, doc comments,
optional/nullable fields, array/list types, deprecated fields,
interface implementation via @compose, and Input suffix logic.
…ed imports

- Add explanatory comment on getComposition/iface.name in object-type.tsx
  clarifying that pre-mutation names match post-mutation names (mutation
  engine doesn't rename models)
- Remove unused `type Model` import from all G2 test files
- Add @operationFields test to ObjectType (verifies operation field rendering)
- Add nested model reference test to ObjectType (verifies type references)
- Add empty model tests to ObjectType, InputType, InterfaceType
  (documents that GraphQL requires at least one field per type)
The mutation engine now handles all input/output type naming, so components
can use type.name directly without looking up whether a model has both
input and output variants.
- Remove implementation detail comments about mutation engine
- Remove redundant tests that were testing non-responsibility of the component
  (InputType doesn't add suffixes - that's not its job)
Replace fragile .toContain() assertions with inline snapshots to match
TSP ecosystem best practices. This makes test output more readable and
maintainable by showing the complete expected SDL in one place.
@FionaBronwen
FionaBronwen force-pushed the feature/graphql branch 2 times, most recently from 59ad903 to 7d69aac Compare June 16, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant